package com.liveneo.adapter.mobile.service.impl;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.liveneo.adapter.base.entity.PrpmAppVersion;
import com.liveneo.adapter.base.mapper.PrpmAppVersionMapper;
import com.liveneo.adapter.mobile.service.PrpmAppVersionService;

/**
 * @Desc：
 * @Title：PrpmAppVersionServiceImpl
 * @address: http://www.liveneo.com.cn/
 * @author: Liuzhipeng
 * @version: 1.0 
 * @date: 2016年10月14日 下午3:50:40
 */
@Service
public class PrpmAppVersionServiceImpl implements PrpmAppVersionService {
    @Autowired
    private PrpmAppVersionMapper prpmAppVersionMapper;

    @Override
    public PrpmAppVersion getVersion(String versionId, String appType, String systemCode) {
        PrpmAppVersion prpmVersion = new PrpmAppVersion();
        prpmVersion.setVersionId(versionId);
        prpmVersion.setSystemCode(systemCode);
        prpmVersion.setAppType(appType);
        return prpmAppVersionMapper.selectByVersionBean(prpmVersion);
    }

    @Override
    public List<PrpmAppVersion> getValidVersions(PrpmAppVersion record) {
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("effectDate", record.getEffectDate());
        paramMap.put("nowTime", new Date());
        paramMap.put("appType", record.getAppType());
        paramMap.put("systemCode", record.getSystemCode());
        paramMap.put("validStatus", record.getValidStatus());
        //paramMap.put("flag", record.getFlag());
        return prpmAppVersionMapper.selectByVersion(paramMap);
    }

    @Override
    public PrpmAppVersion getPreVersion(String versionId, String appType, String systemCode) {
        PrpmAppVersion prpmVersion = new PrpmAppVersion();
        prpmVersion.setVersionId(versionId);
        prpmVersion.setSystemCode(systemCode);
        prpmVersion.setAppType(appType);
        return prpmAppVersionMapper.selectByPreVersionBean(prpmVersion);
    }
}
